package com.ysjweb.dish.Controller;


import com.ysjweb.dish.pojo.Result;
import com.ysjweb.dish.tool.Upload;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@Slf4j
@RestController
public class Uploader {
    @Autowired
    private Upload uploadertool;
    @PostMapping("/upload")
    public Result Upload(MultipartFile file) throws IOException {//这里的接受名如果不使用@Param就必须保持一致
        log.info("文件上传{}",file.getOriginalFilename());
        String url=uploadertool.upload(file);
        return Result.success(url);
    }
}
